<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <script>
   

    new Promise((resolve, reject) => {
      // resolve(1)
      reject(2)
    }).then(
      value => {
        console.log('onResolved1', value)
      },
      reason => {
        // console.log('onRejected1', reason)
        // 1. 抛出错误 
        // throw 3

        // 2. 返回一个失败的promise 
        // return Promise.reject(4)

        // 3. 返回一个成功的promise
        // return Promise.resolve(5)

        // 4. 返回其它值(包含没有return)
        // return 6

        // 5. 返回一个pending状态的promise => pending状态
        return new Promise(() => {})
      }
    ).then(
      value => {
        console.log('1', value)  // 1
      },
      reason => {
        console.log('2', reason) // 2
      }
    )

    
  </script>
</body>
</html>